package com.dlwx.parttimetalent.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.base.BaseActivity;
import com.dlwx.parttimetalent.comm.Constant;
import com.dlwx.parttimetalent.utils.DialogUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CertificateResActivity extends BaseActivity {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.tv_middle_title)
    TextView tvMiddleTitle;
    @BindView(R.id.image)
    ImageView image;
    @BindView(R.id.tv_res)
    TextView tvRes;
    @BindView(R.id.tv_result)
    TextView tvResult;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    @BindView(R.id.ll_confirm)
    LinearLayout llConfirm;
    private String reason;
    private int flag;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_certificate_res);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        tvMiddleTitle.setText("认证中心");
        tvMiddleTitle.setVisibility(View.VISIBLE);
        titleLeftOneBtn.setVisibility(View.VISIBLE);
        Intent i=getIntent();
        int type = i.getIntExtra("type", 0);
        switch (type) {
            case Constant.STATUS_ERROR:
                flag=i.getIntExtra("flag",-1);
                reason=i.getStringExtra("reason");
                tvRes.setText("很遗憾，您未通过审核...");
                Glide.with(CertificateResActivity.this).load(R.mipmap.icon_rzshshenheshibai).into(image);
                break;
            case Constant.STATUS_ING:
                Glide.with(CertificateResActivity.this).load(R.mipmap.icon_rzshshenhezhong).into(image);
                tvRes.setText("您的认证已经提交审核，请耐心等待");
                llConfirm.setVisibility(View.INVISIBLE);
                break;
            case Constant.STATUS_RIGHT:
                Glide.with(CertificateResActivity.this).load(R.mipmap.icon_ezshshenhechenggong).into(image);
                tvRes.setText("恭喜您审核成功");
                llConfirm.setVisibility(View.INVISIBLE);
                break;
        }
    }

    @OnClick({R.id.title_left_one_btn, R.id.tv_result, R.id.tv_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_left_one_btn:
                this.finish();
                break;
            case R.id.tv_result:
                DialogUtils.getMaterialDialogOneBtn(this, reason).show();
                break;
            case R.id.tv_confirm:
                switch (flag){
                    case Constant.ZERO:
                        startActivity(new Intent(CertificateResActivity.this,IdentityActivity.class));
                        break;
                    case Constant.ONE:
                        startActivity(new Intent(CertificateResActivity.this,SkillCertifyActivity.class));
                        break;
                    case Constant.TWO:
                        startActivity(new Intent(CertificateResActivity.this,EducateActivity.class));
                        break;
                    case Constant.THREE:
                        startActivity(new Intent(CertificateResActivity.this,DriverActivity.class));
                        break;
                }

                break;
        }
    }
}
